package com.example.shop_car_2208.adapter

import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.widget.LinearLayout
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.shop_car_2208.R
import com.example.shop_car_2208.entity.CateEntity

import com.example.shop_car_2208.utils.GlideUtils

class GateAdapter(list: MutableList<CateEntity>): BaseQuickAdapter<CateEntity,BaseViewHolder>(R.layout.item_catr,list) {
    private var selecedId = 14//默认选中的id
    override fun convert(holder: BaseViewHolder, item: CateEntity) {
        holder.setText(R.id.cate_tv,item.category_name)

            GlideUtils.loafImage(context,holder.getView(R.id.image_iv), item.category_icon)
        holder.getView<LinearLayout>(R.id.tt).background = if(selecedId == item.id){
            ColorDrawable(Color.MAGENTA)
        }else null



    }
    fun getSeleceId(id:Int){
        selecedId = id
        notifyDataSetChanged()
    }

}